#ifndef __BUTTON_H__
#define __BUTTON_H__
#include "gd32f10x.h"

typedef enum 
{
    Release = 0,
    Pressed,
    LongPressed,
}BtnState;

typedef enum
{
    Btn_Power = 0,
    Btn_Mode,
    Btn_Speed,
    Btn_Down,
    Btn_Up,
    Btn_Page,
    
    BUTTON_NUM
}BtnID;

typedef struct
{
    BtnID       id;                 
    BtnState    state;              //按键状态
    uint8_t     pressTimeOnce;      //单次按键按下的时间
    uint16_t    pressTimeSum;       //按键按下的累计时间
    uint8_t     pressTimeMin;       //识别到press的时间
    uint16_t    longPressTimeMin;   //识别到longPress的时间
    uint8_t     flag;               //已生成键值，需释放按键
    uint8_t     buzzerCnt;          //蜂鸣器响计数
    uint32_t    gpio_periph;        //GPIO_Port
    uint32_t    pin;                //GPIO_Pin
}Button;

void button_init(void);
void button_scan(void);
BtnState button_get_state(uint8_t id);
#endif
